package com.app.enums;

import com.app.config.SpringContextUtil;
import com.app.service.InnerCommand;
import com.app.service.impl.UserSysServiceImpl1;
import com.app.service.impl.UserSysServiceImpl2;

/**
 * @author xiaoyu.fang
 * @date 2019/12/25 11:15
 */
public enum SystemAllSourceEnums {

    USER_SYS(1) {
        @Override
        public InnerCommand getClassBySource() {
            return SpringContextUtil.getBean(UserSysServiceImpl1.class);
        }
    }, USER_SERVER(2) {
        @Override
        public InnerCommand getClassBySource() {
            return SpringContextUtil.getBean(UserSysServiceImpl2.class);
        }
    };

    SystemAllSourceEnums(int value) {
        this.value = value;
    }

    private int value;

    public InnerCommand getClassBySource() {
        return null;
    }

    public static SystemAllSourceEnums getByValue(int value) {
        for (SystemAllSourceEnums systemAllSourceEnums : values()) {
            if (systemAllSourceEnums.value == value) {
                return systemAllSourceEnums;
            }
        }
        return null;
    }
}
